﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MSBDATAModel;

public partial class Admin_CauHinhThongTin : System.Web.UI.Page
{
    MSBDATAEntities entities = new MSBDATAEntities();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            int cauHinhID = 1;
            var matches = from c in entities.C_CAU_HINH
                          where c.Ma == cauHinhID
                          select c;
            C_CAU_HINH ch = matches.First();

            this.TextBoxDiaChi.Text = ch.DiaChi;
            this.TextBoxDienThoai.Text = ch.SoDienThoai;
            this.TextBoxEmail.Text = ch.Email;
            this.TextBoxGioiThieu.Text = ch.LoiGioiThieu;
            this.TextBoxMaGiaoDich.Text = ch.MaGiaoDich;
            this.TextBoxTenNganHang.Text = ch.TenNH;
            this.TextBoxMatKhauMail.Text = ch.PassMail;
            this.TextBoxLinkKHTK.Text = ch.LinkKichHoat;
            this.TextBoxLinkECCard.Text = ch.LinkECCardWS;
            this.TextBoxPassECCard.Text = ch.PassECCardWS;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int cauHinhID = 1;
        var matches = from c in entities.C_CAU_HINH
                      where c.Ma == cauHinhID
                      select c;
        C_CAU_HINH ch = matches.First();
        ch.DiaChi = this.TextBoxDiaChi.Text;
        ch.SoDienThoai = this.TextBoxDienThoai.Text;
        ch.Email = this.TextBoxEmail.Text;
        ch.LoiGioiThieu = this.TextBoxGioiThieu.Text;
        ch.MaGiaoDich = this.TextBoxMaGiaoDich.Text;
        ch.TenNH = this.TextBoxTenNganHang.Text;
        ch.PassMail = this.TextBoxMatKhauMail.Text;
        ch.LinkECCardWS = this.TextBoxLinkECCard.Text;
        ch.PassECCardWS = this.TextBoxPassECCard.Text;
        ch.LinkKichHoat = this.TextBoxLinkKHTK.Text;
        entities.SaveChanges();
    }
}